﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Linq.Expressions;
using JXT.PrimaryKey.Batman.Domain.Models;

namespace JXT.PrimaryKey.Batman.Domain.Repositories.SqlServer.Expressions {
    public class OrderQuery<TEntity> : OrderQuery where TEntity : IEntity {
        public OrderQuery()
            : base() {
        }

        public void Descending<TKey>(Expression<Func<TEntity, TKey>> selector) {
            ColumnExpressionVisitor columnExpressionVisitor = new ColumnExpressionVisitor(selector.Body);
            Descending(columnExpressionVisitor.GetColumnString());
        }

        public void Descending(Expression selector)
        {
            ColumnExpressionVisitor columnExpressionVisitor = new ColumnExpressionVisitor(selector);
            Descending(columnExpressionVisitor.GetColumnString());
        }

        public void Ascending<TKey>(Expression<Func<TEntity, TKey>> selector) {
            ColumnExpressionVisitor columnExpressionVisitor = new ColumnExpressionVisitor(selector.Body);
            Ascending(columnExpressionVisitor.GetColumnString());
        }

        public void Ascending(Expression selector)
        {
            ColumnExpressionVisitor columnExpressionVisitor = new ColumnExpressionVisitor(selector);
            Ascending(columnExpressionVisitor.GetColumnString());
        }
    }
}
